/*
 * Sesame Inc.
 * Copyright (c) 2009 All Rights Reserved.
 */
package com.sesame.daoimpl;

import java.util.List;

import org.springframework.orm.ibatis.support.SqlMapClientDaoSupport;

import com.sesame.dao.NoticeDAO;
import com.sesame.domain.Notice;

/**
 * @author shubeta
 * 
 */
public class NoticeDAOImpl extends SqlMapClientDaoSupport implements NoticeDAO {

    public void addNotice(Notice notice) {
        getSqlMapClientTemplate().insert("addNotice", notice);
    }

    public void deleteNoticeById(Integer id) {
        getSqlMapClientTemplate().delete("deleteNoticeById", id);
    }

    public Notice getNoticeByTitle(String title) {
        return (Notice) getSqlMapClientTemplate().queryForObject(
                "getNoticeByTitle", title);
    }

    @SuppressWarnings("unchecked")
    public List<Notice> getAllNotice() {
        return (List<Notice>) getSqlMapClientTemplate().queryForList(
                "getAllNotice");
    }
    
    public List<Notice> getTopNotice() {
        return (List<Notice>) getSqlMapClientTemplate().queryForList(
                "getTopNotice");
    }
    
    public Notice getNoticeById(Integer id) {
        return (Notice) getSqlMapClientTemplate().queryForObject(
                "getNoticeById", id);
    }

    public void updateNotice(Notice notice) {
        getSqlMapClientTemplate().update("updateNotice", notice);
    }

}